package com.yxinsur.imc.web.controller.business;

import com.yxinsur.imc.business.domain.ImcSupplierPersistencyConfig;
import com.yxinsur.imc.business.form.ImcSuppierPersistencyForm;
import com.yxinsur.imc.business.service.IImcSupplierPersistencyConfigService;
import com.yxinsur.imc.business.vo.PersistencyConfigVo;
import com.yxinsur.imc.common.annotation.Log;
import com.yxinsur.imc.common.core.controller.BaseController;
import com.yxinsur.imc.common.core.domain.AjaxResult;
import com.yxinsur.imc.common.core.page.TableDataInfo;
import com.yxinsur.imc.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 保险公司继续率计算规则配置Controller
 *
 * @author imc
 * @date 2021-09-22
 */
@Api(value="保险公司继续率计算规则配置",tags={"保险公司继续率计算规则配置"})
@RestController
@RequestMapping("/business/persistency/config")
public class ImcSupplierPersistencyConfigController extends BaseController {
    @Autowired
    private IImcSupplierPersistencyConfigService imcSupplierPersistencyConfigService;

    /**
     * 查询保险公司继续率计算规则配置列表
     */
    @ApiOperation("查询保险公司继续率计算规则配置列表")
    @GetMapping("/list")
    public TableDataInfo list(ImcSuppierPersistencyForm imcSuppierPersistencyForm) {
        startPage();
        List<PersistencyConfigVo> list = imcSupplierPersistencyConfigService.selectImcSupplierPersistencyConfigList(imcSuppierPersistencyForm);
        return getDataTable(list);
    }


    /**
     * 获取保险公司继续率计算规则配置详细信息
     */
    @ApiOperation("获取保险公司继续率计算规则配置详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(imcSupplierPersistencyConfigService.selectImcSupplierPersistencyConfigById(id));
    }

    /**
     * 新增保险公司继续率计算规则配置
     */
    @ApiOperation("新增保险公司继续率计算规则配置")
    @Log(title = "新增保险公司继续率计算规则配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ImcSuppierPersistencyForm imcSuppierPersistencyForm) {
        return toAjax(imcSupplierPersistencyConfigService.insertImcSupplierPersistencyConfig(imcSuppierPersistencyForm));
    }

    /**
     * 修改保险公司继续率计算规则配置
     */
    @ApiOperation("修改保险公司继续率计算规则配置")
    @Log(title = "修改保险公司继续率计算规则配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ImcSuppierPersistencyForm imcSuppierPersistencyForm) {
        return toAjax(imcSupplierPersistencyConfigService.updateImcSupplierPersistencyConfig(imcSuppierPersistencyForm));
    }

    /**
     * 删除保险公司继续率计算规则配置
     */
    @ApiOperation("删除保险公司继续率计算规则配置")
    @Log(title = "删除保险公司继续率计算规则配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(imcSupplierPersistencyConfigService.deleteImcSupplierPersistencyConfigByIds(ids));
    }
}
